using System;
using System.Collections.Generic;
using System.Text;
using System.Globalization;
using LeisureCenter.MetadataHandlers;

namespace LeisureCenter.Tools
{
    public static class SQLiteTools
    {
        public static string ReturnNullIfNeeded(int? n)
        {
            if (n.HasValue)
            {
                return n.Value.ToString(CultureInfo.InvariantCulture);
            }
            else
            {
                return "null";
            }
        }

        public static string ReturnNullIfNeeded(VideoType? n)
        {
            if (n.HasValue)
            {
                return ((int)n.Value).ToString(CultureInfo.InvariantCulture);
            }
            else
            {
                return "null";
            }
        }

        public static string ReturnNullIfNeeded(double? n)
        {
            if (n.HasValue)
            {
                return n.Value.ToString(CultureInfo.InvariantCulture);
            }
            else
            {
                return "null";
            }
        }

        public static string EscapeSqlString(string str)
        {
            if (str == null)
            {
                return "";
            }
            else
            {
                return str.Replace(@"'", @"''").Replace('\0', ' ');
            }
        }


    }
}
